from Page.page1 import Page1

from selenium.webdriver.common.by import By
import time

#积分商城
class Page2(Page1):
    #首页  /html/body/div[3]/div[2]/ul/li[1]/a
    sho_loc = (By.XPATH, '/html/body/div[3]/div[2]/ul/li[1]/a')

    def sho(self):
        self.click(self.sho_loc)

    #积分商城  /html/body/div[3]/div[2]/ul/li[6]/a

    jfsc_loc = (By.XPATH, '/html/body/div[3]/div[2]/ul/li[6]/a')

    def jfsc(self):
        self.click(self.jfsc_loc)

    #断言 积分商城 /html/body/div[4]/a[2]

    dy3_loc = (By.XPATH, '/html/body/div[4]/a[2]')

    def dy3(self):
        return self.text(self.dy3_loc)

    #购买商品 /html/body/div[5]/div[2]/div[2]/div[1]/ul/li[2]/div[1]/span/a/img
    gmsp_loc = (By.XPATH, '/html/body/div[5]/div[2]/div[2]/div[1]/ul/li[2]/div[1]/span/a/img')

    def gmsp(self):
        self.click(self.gmsp_loc)

    #断言 傻子大甩卖  //*[@id="goodsForm"]/div/div[1]/span

    dy4_loc = (By.XPATH, '//*[@id="goodsForm"]/div/div[1]/span')

    def dy4(self):
        return self.text(self.dy4_loc)

    #点击兑换  id="buy-cart"

    dh_loc = (By.ID, 'buy-cart')

    def dh(self):
        self.click(self.dh_loc)

    # 断言确认订单   /html/body/div[4]/div[1]/a[2]

    dy5_loc = (By.XPATH, '/html/body/div[4]/div[1]/a[2]')

    def dy5(self):
        return self.text(self.dy5_loc)

    #选择收获地址   //*[@id="address-278"]
    shdz_loc = (By.XPATH, '//*[@id="address-15"]')

    def shdz(self):
        self.click(self.shdz_loc)

    #选择支付方式   name="payment"

    zffs_loc = (By.NAME, 'payment')

    def zffs(self):
        self.click(self.zffs_loc)

    #下一步  id="order-button"

    xib_loc = (By.ID, 'order-button')

    def xib(self):
        self.click(self.xib_loc)

    #断言订单完成 /html/body/div[4]/div[1]/a[2]
    dy6_loc = (By.XPATH, '/html/body/div[4]/div[1]/a[2]')

    def dy6(self):
        return self.text(self.dy6_loc)

    #点击查看订单 /html/body/div[4]/div[3]/p/a

    ckdd_loc = (By.XPATH, '/html/body/div[4]/div[3]/p/a')

    def ckdd(self):
        self.click(self.ckdd_loc)

    def test_A3mall_002(self):
        self.test_A3mall_001()
        time.sleep(3)
        self.sho()
        self.jfsc()
        time.sleep(3)
        self.dy3()
        self.gmsp()
        time.sleep(3)
        self.dy4()
        self.dh()
        time.sleep(3)
        self.dy5()
        self.shdz()
        time.sleep(3)
        self.xib()
        self.dy6()
        time.sleep(2)
        self.ckdd()
